class Solution {
public:
    int findKthPositive(vector<int>& arr, int k) {
        int x,l=0;
        int r=arr.size();
        while(l<r){
            int mid=(l+r)/2;
            if(mid < r)  x=arr[mid];
            else x=INT_MAX; 

            if(x-mid-1>=k){
                r=mid;
            }else{
                l=mid+1;
            }
        }
        return k+l;
    }
};
